﻿@using NetCoreCMS.Models;
@inject NetCoreCMS.IServices.IUsersService _users;
@inject NetCoreCMS.IServices.IManagerService _manager;
@{
    Layout = "~/Areas/admin/Views/Shared/_LayoutList.cshtml";
    ViewBag.Title = "Apply_List";
    List<Apply> list = ViewData["list"] as List<Apply>;
}
@section HeaderContent{
    <script>
        //查询数据
        function search() {
            var text = $(".keyword").val();
            var pageCount = $("#txtPageNum").val();
            document.location = "index?keywords=" + text + "&pageNum=" + pageCount;
        }

        //ExePostBack回调函数
    function __doPostBack(objId) {
        if (objId == "btnDelete") {
            submitDelete();
        }
        if (objId == "btnSend") {
            submitSend();
        }
        if (objId == "btnCancel") {
            submitCancel();
        }
        }
        //删除
    function submitDelete() {
        var text = $("#txtKeywords").val();
        var $row = $("#ltable tr:gt(0)");
        var json = { list: [] };
        $($row).each(function (i, item) {
            if ($(item).find("input:checkbox").prop("checked")) {
                var id = $(item).find("td:eq(0)").find("label:eq(0)").text();
                var obj = { id: id };
                json.list.push(obj);
            }
        });
        $.ajax({
            url: "SubmitDelete?keywords=" + text,
            type: "POST",
            dataType: "html",
            data: "json=" + JSON.stringify(json),
            success: function (data) {
                eval(data);
            },
            error: function () {
                alert("error");
            }
        });
    }
    //发放
    function submitSend() {
        var text = $("#txtKeywords").val();
        var $row = $("#ltable tr:gt(0)");
        var json = { list: [] };
        $($row).each(function (i, item) {
            if ($(item).find("input:checkbox").prop("checked")) {
                var id = $(item).find("td:eq(0)").find("label:eq(0)").text();
                var obj = { id: id };
                json.list.push(obj);
            }
        });
        $.ajax({
            url: "SubmitSend?keywords=" + text,
            type: "POST",
            dataType: "html",
            data: "json=" + JSON.stringify(json),
            success: function (data) {
                eval(data);
            },
            error: function () {
                alert("error");
            }
        });
    }
    //退回
    function submitCancel() {
        var text = $("#txtKeywords").val();
        var $row = $("#ltable tr:gt(0)");
        var json = { list: [] };
        $($row).each(function (i, item) {
            if ($(item).find("input:checkbox").prop("checked")) {
                var id = $(item).find("td:eq(0)").find("label:eq(0)").text();
                var obj = { id: id };
                json.list.push(obj);
            }
        });
        $.ajax({
            url: "SubmitCancel?keywords=" + text,
            type: "POST",
            dataType: "html",
            data: "json=" + JSON.stringify(json),
            success: function (data) {
                eval(data);
            },
            error: function () {
                alert("error");
            }
        });
    }
    </script>
}
<form id="form1" method="post" action="#">
    <!--导航栏-->
    <div class="location">
        <a href="javascript:history.back(-1);" class="back"><i class="iconfont icon-up"></i><span>返回上一页</span></a>
        <a href="../center/index"><i class="iconfont icon-home"></i><span>首页</span></a>
        <i class="arrow iconfont icon-arrow-right"></i>
        <a href="../finance_list/index"><span>会员列表</span></a>
        <i class="arrow iconfont icon-arrow-right"></i>
        <span>申请记录</span>
    </div>
    <!--/导航栏-->
    <!--工具栏-->
    <div id="floatHead" class="toolbar-wrap">
        <div class="toolbar">
            <div class="box-wrap">
                <a class="menu-btn"><i class="iconfont icon-more"></i></a><a class="menu-btn"><i class="iconfont icon-more"></i></a>
                <div class="l-list">
                    <ul class="icon-list">
                        <li><a href="javascript:;" onclick="checkAll(this);"><i class="iconfont icon-check"></i><span>全选</span></a></li>
                        <li><a href="javascript:;" onclick="ExePostBack('btnDelete');"><i class="iconfont icon-delete"></i><span>删除</span></a></li>
                        <li><a href="javascript:;" onclick="ExePostBack('btnSend');"><i class="iconfont icon-open"></i><span>发放</span></a></li>
                        <li><a href="javascript:;" onclick="ExePostBack('btnCancel');"><i class="iconfont icon-bad"></i><span>退回</span></a></li>
                        <li><a href="SubmitExport" target="_blank"><i class="iconfont icon-exl"></i><span>导出</span></a></li>
                    </ul>
                </div>
                <div class="r-list">
                    <input id="txtKeywords" type="text" class="keyword" value="@ViewBag.Keywords" />
                    <a href="javascript:search();" id="lbtnSearch" class="btn-search"><i class="iconfont icon-search"></i></a>
                </div>
            </div>
        </div>
    </div>
    <!--/工具栏-->
    <!--列表-->
    <div class="table-container">
        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="ltable" id="ltable">
            <tr>
                <th width="8%">选择</th>
                <th align="left" width="10%">用户名</th>
                <th align="left" width="8%">申请</th>
                <th align="left" width="8%">发放</th>
                <th align="left" width="8%">状态</th>
                <th align="left">备注</th>
                <th align="left" width="10%">发放时间</th>
                <th align="left" width="8%">发放人</th>
                <th align="left" width="8%">退回时间</th>
                <th align="left" width="8%">退回人</th>
                <th align="left" width="10%">申请时间</th>
            </tr>
            @foreach (Apply dr in list)
            {
                var user = _users.GetModel(dr.user_id);
                string user_name = "已删除";
                if(user!=null)
                {
                    user_name = user.user_name;
                }
                var sender = _manager.GetModel(dr.send_user_id);
                var canceler = _manager.GetModel(dr.cancel_user_id);
                string suser_name = "已删除";
                string cuser_name = "已删除";
                if(sender!=null)
                {
                    suser_name = sender.user_name;
                }
                if(canceler!=null)
                {
                    cuser_name = canceler.user_name;
                }
        <tr>
            <td align="center">
                <span class="checkall" style="vertical-align:middle;">
                    <input type="checkbox" />
                </span>
                <label style="display:none">@dr.id</label>
            </td>
            <td>@user_name</td>
            <td>@dr.apply_point</td>
            <td>@dr.send_point</td>
            <td>@dr.send_cancel</td>
            <td>@dr.remark</td>
            <td>@dr.send_time?.ToString("yyyy-MM-dd hh:mm:sss")</td>
            <td>@suser_name</td>
            <td>@dr.cancel_time?.ToString("yyyy-MM-dd hh:mm:sss")</td>
            <td>@cuser_name</td>
            <td>@dr.add_time.ToString("yyyy-MM-dd hh:mm:sss")</td>
        </tr>
            }
            @if (list.Count == 0)
            {
                <tr><td align="center" colspan="11">暂无记录</td></tr>
            }
        </table>
    </div>
    <!--/列表-->
    <!--内容底部-->
    <div class="line20"></div>
    <div class="pagelist">
        <div class="l-btns">
            <span>显示</span>
            <input type="text" id="txtPageNum" class="pagenum" onkeydown="return checkNumber(event);" onchange="search();" value="@ViewBag.PageNum" />
            <span>条/页</span>
        </div>
        <div class="default">@Html.Raw(ViewBag.PageContent)</div>
    </div>
    <!--/内容底部-->

</form>
